<?php
declare (strict_types = 1);

namespace app\middleware;

class CheckApi
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        if (!(strtolower($request->action()) == 'login')){
            $token = $_SERVER['HTTP_TOKEN'];
            $res = checkToken($token);
            if ($res['code'] == 1){
                return $next($request);
            }
        }
        return $next($request);
    }
}
